﻿@using Microsoft.Extensions.Primitives
<div>
    <AutoComplete @ref="@_autoComplete" @bind-Value="@txtValue">
        <CustomInput>
            <TextArea Placeholder="input here" AutoSize="true" OnChange="OnChange" @bind-Value="@txtValue" @onkeydown="(e)=>_autoComplete.OnKeyDown(e)"/>
        </CustomInput>
    </AutoComplete>
</div>

@code
{
    private AutoComplete _autoComplete;
    private string txtValue;

    private void OnChange(string value)
    {
        var list = string.IsNullOrWhiteSpace(value) ? Array.Empty<string>() : new[]
        {
            value,
            value + value,
            value + value + value
        };
        _autoComplete.LoadData(list);
    }
}